Skip to content

feat(tron-wallet-snap): route fungible reads through Core AssetsController - #96

Draft
ulissesferreira wants to merge 3 commits into
WPN-1497-messenger-plumbingfrom
WPN-1497-core-adapter-routing
Draft

feat(tron-wallet-snap): route fungible reads through Core AssetsController#96
ulissesferreira wants to merge 3 commits into
WPN-1497-messenger-plumbingfrom
WPN-1497-core-adapter-routing

Conversation

@ulissesferreira

Copy link
Copy Markdown
Contributor

Summary

  • Introduce CoreAssetsAdapter and mapControllerAsset for Core AssetsController reads
  • Route fungible asset reads (TRX, TRC10, TRC20) based on resolved migration stage (Off / ReadWithFallback / Read)
  • Snap-owned assets always use SnapAssetsAdapter; narrow sync/saveMany to snap-owned when Core stage is active
  • Manifest endows AssetsController:getAsset and AssetsController:getAssets

Part 2 of 2 split from #94. Part 1: WPN-1497-messenger-plumbing.

Jira

Test plan

  • yarn workspace @metamask/tron-wallet-snap build
  • yarn workspace @metamask/tron-wallet-snap run jest --no-coverage (898 tests)

Stacks on PR 1 (WPN-1497-messenger-plumbing), which stacks on #92.

Supersedes #94.

@ulissesferreira
ulissesferreira requested a review from a team as a code owner July 31, 2026 22:08
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-messenger-plumbing branch from 2339dbc to 1413a43 Compare July 31, 2026 22:32
@ulissesferreira
ulissesferreira requested a review from a team as a code owner July 31, 2026 22:32
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-core-adapter-routing branch from 3e08eaa to c278782 Compare July 31, 2026 22:36
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-core-adapter-routing branch from e6ff082 to 7e28dbf Compare July 31, 2026 22:45
@ulissesferreira
ulissesferreira marked this pull request as draft August 2, 2026 17:39
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-messenger-plumbing branch from e2a7495 to 64e6d11 Compare August 2, 2026 20:48
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-core-adapter-routing branch 2 times, most recently from 01f94f8 to aec97ce Compare August 2, 2026 20:59
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-messenger-plumbing branch from b73d987 to 7302e9d Compare August 2, 2026 23:20
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-core-adapter-routing branch from 6f74385 to 1ad0e7a Compare August 2, 2026 23:20
): Promise<AssetEntity | null> {
if (isSnapOwnedAsset(assetId)) {
return this.#snapAdapter.getAccountAssetByID(accountId, assetId);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't exist

return ASSETS_MIGRATION_STAGE;
}

async #getProviderAccountAssetByID(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary indirection

return mapControllerAsset(accountId, asset);
}

async #getProviderAccountAssetsByIDs(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary indirection

);
}

async #getProviderAccountAssetsByScope(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary indirection

}

return this.#getProviderAccountAssetByID(accountId, assetId);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the fallback thing. Just an if with an early return and everything else

@cursor
cursor Bot force-pushed the WPN-1497-messenger-plumbing branch from f5bde1f to f53d7bf Compare August 4, 2026 11:09
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-messenger-plumbing branch from f53d7bf to c9d4f0c Compare August 4, 2026 13:45
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-core-adapter-routing branch from 1a63feb to 3dc547d Compare August 4, 2026 13:45
ulissesferreira and others added 3 commits August 4, 2026 14:53
Bump devDependency to match snap-networks-utils baseline. Update
AssetsService test mocks for v13 SnapsAssetsMigrationStage enum names
and RemoteFeatureFlagController:getState return shape.

Co-authored-by: Cursor <cursoragent@cursor.com>
…vider

Adopt @metamask/snap-networks-utils AssetsProvider from day one for
account-scoped AssetsController reads (getAccountAssetByID,
getAccountAssetsByIDs, getAccountAssetsByScope) behind migration-stage
routing in AssetsService. Map controller Asset shapes to private
AssetEntity via mapControllerAsset; protocol assets remain Snap-owned
through SnapAssetsAdapter. CoreAssetsAdapter is not used.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-messenger-plumbing branch from c9d4f0c to d5a852a Compare August 4, 2026 13:54
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-core-adapter-routing branch from 3dc547d to d387059 Compare August 4, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant